<template>
	<view class="home">
		<view class="item">
			<view class="">顾客昵称:<text>{{details.name}}</text></view>
			<view class="">金额:<text>{{details.money}}元</text></view>
			<view class="">顾客电话:<text>{{details.telephone_number}}</text></view>
			<view class="">送达地点:<text>{{details.give_Address}}</text></view>
			<view class="">备注:<text>{{details.Notes}}</text></view>
		</view>
		
		<button type="primary" class="button" @click="Get">确定</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				details:{},
				User:{}
			}
		},
		methods: {
			Get(){
				uni.showModal({
					title:'温馨提示',
					content:'你确定要接手吗?',
					success:(res)=>{
						if(res.confirm){
							this.nav();
						}
					}
				})
			},
			nav(){
				this.User = getApp().globalData.User;
				// console.log(this.User,'新')
				
				if ((JSON.stringify(this.User)) == '{}') {
					uni.showToast({
						title: '你还未登录哦'
					})
					return;
				}
				
				if(this.User.code == 0){
					if (this.User.message.if_runner == 0) {
						uni.showToast({
							title: '你还不是跑手哦'
						})
						return;
					}
					console.log('111')
					if(this.User.message.student_number == this.details.number){
						uni.showToast({
							title: '这是自己发布的'
						})
						return;
					}else{
						this.Select_PrintTask(this.details.number,this.details.id,this.User.message.student_number)
					}
				}else{
					if (this.User.if_runner == 0) {
						uni.showToast({
							title: '你还不是跑手哦'
						})
						return;
					}
					
					if(this.User.student_number == this.details.number){
						uni.showToast({
							title: '这是自己发布的'
						})
						return;
					}else{
						this.Select_PrintTask(this.details.number,this.details.id,this.User.student_number)
					}
				}
			},
			async Select_PrintTask(number,id,Select_number){
				const res = await uni.request({
					url:`http://3888n9t950.wicp.vip/Get_PrintTask?id=${id}&number=${number}&Select_number=${Select_number}`
				})
				// const res = await this.$myRequest({
				// 	url: `/Get_PrintTask?id=${id}&number=${number}&Select_number=${Select_number}`
				// })
				// 改成全局接口请求的封装
				console.log(res)
				if(res[1].data.code == 0){
					uni.$emit('Select_PrintTask');
					uni.navigateBack({
						delta:1
					})
				}
			}
		},
		onLoad(){
			this.details = getApp().globalData.Print;
		}
	}
</script>

<style lang="scss">
	.home{
		width: 100%;
		.item{
			width: 100%;
			font-size: 28rpx;
			margin-top: 20px;
			
			view{
				width: 690rpx;
				height: 140rpx;
				line-height: 140rpx;
				border-bottom: 1px solid #C0C0C0;
				display: flex;
				margin: 0 auto;
				
				text{
					display: block;
					margin-left: 50rpx;
				}
			}
		}
		
		.button{
			position: fixed;
			bottom: 80rpx;
			left:50%;
			font-size: 32rpx;
			transform: translateX(-50%);
			background-color: $main-color;
			width: 90%;
		}
		button::after{
			border: none;
		}
	}
</style>
